$(document).ready(function () {
    showMenuInfo();
});
function showMenuInfo() {
    $.ajax({
        url: "/User/GetMenuInfo",
        type: "POST",
        data: {},
        success: function (result) {
            $("#userName").html(result);
        }
    })
}
function chooseInventory(inventoryId) {
    $.ajax({
        url: "/Inventory/ChooseInventory",
        type: "POST",
        data: { inventoryId: inventoryId },
        success: function (result) {
            $("#right-top-content").html(result);
            $("#write-matter-content").html("");
            $("#show-matter-content").html("");
            $("#show-matter-remark").html("");
            $("#matter-date").html("<span onclick=\"getDetailMatter(0)\"><img id=\"detail\" src=\"/images/详细.png\" ></span>");
        }
    })
}
function chooseMatter(matterId) {
    $.ajax({
        url: "/Matter/ChooseMatter",
        type: "POST",
        data: { matterId: matterId },
        success: function (result) {
            $("#show-matter-content").html(result);
        }
    }),
        $.ajax({
            url: "/Matter/ShowMatterRemark",
            type: "POST",
            data: { matterId: matterId },
            success: function (result) {
                $("#left-bottom-title").html("<p id=\"matter-content\">事项内容</p>" +
                    "<a id=\"a-compile-matter\" href=\"/Matter/CompileMatterView?matterId=" + matterId + "\"><img id=\"compile-img-matter\" src=\"/images/编辑.png\"></a>" +
                    "<span id=\"matter-date\"><span onclick=\"getDetailMatter(" + matterId + ")\"><img id=\"detail\" src=\"/images/详细.png\" ></span></span>");
                $("#show-matter-remark").html(result);
            }
        })
}
function changeIsFinished(matterId) {
    $.ajax({
        url: "/Matter/ChangeIsFinished",
        type: "POST",
        data: { matterId: matterId },
        success: function (result) {
            $("#right-top-content").html(result);
        }
    })
}

function getDetailMatter(matterId) {
    if (matterId != 0) {
        $.ajax({
            url: "/Matter/GetDetailMatter",
            type: "POST",
            data: { matterId: matterId },
            success: function (result) {
                $("#extend-box").html(result);
                showExtendBox();
            }
        })
    }
}

function addMatter() {
    $.ajax({
        url: "/Matter/AddMatter",
        type: "POST",
        data: {},
        success: function (result) {
            $("#extend-box").html(result);
            showExtendBox();
        }
    })
}

function addInventory() {
    slideUpType();
    $.ajax({
        url: "/Inventory/AddInventory",
        type: "POST",
        data: $("#pull-down-form").serialize(),
        success: function (result) {
            $("#inventorys").html(result);
            pullDownAdd();
        }
    })
}

function addType() {
    slideUpType();
    $.ajax({
        url: "/Type/FoundType",
        type: "POST",
        data: $("#pull-down-form").serialize(),
        success: function (result) {
            $("#inventorys").html(result);
            pullDownAdd();
        }
    })
}

function deleteType(typeId) {
    if (confirm("确定删除该类型吗？")) {
        $.ajax({
            url: "/Type/DeleteType",
            type: "POST",
            data: { typeId: typeId },
            success: function (result) {
                $("#inventorys").html(result);
            }
        })
    }
}

function deleteInventory(inventoryId) {
    if (confirm("确定删除该清单吗？")) {
        $.ajax({
            url: "/Inventory/DeleteInventory",
            type: "POST",
            data: { inventoryId: inventoryId },
            success: function (result) {
                $("#inventorys").html(result);
                $("#right-top-content").html("");
                $("#show-matter-content").html("");
                $("#show-matter-remark").html("");
            }
        })
    }
}

function deleteMatter(userId,matterId) {
    if (confirm("确认删除该事项吗？")) {
        $.ajax({
            url: "/Type/DeleteMatters",
            type: "GET",
            data: { userId:userId,matterId:matterId },
            success: function (result) {
                $("#right-top-content").html(result);
            }
        })
    }// window.location.reload(); 
    parent.location.reload();//刷新父亲对象
}

function foundMatter() {
    $.ajax({
        url: "/Matter/FoundMatter",
        type: "POST",
        data: $("#form-found-matter").serialize(),
        success: function (result) {
            $("#right-top-content").html(result);
            concealExtendBox();
        }
    })
}

function createType() {
    $.ajax({
        url: "/Type/AddTypeView",
        type: "POST",
        data: {},
        success: function (result) {
            slideUpPullDownAdd();
            $("#pull-down-form").html(result);
            $("#pull-down-form").slideToggle("1000");
        }
    })
}

function createInventory() {
    $.ajax({
        url: "/Inventory/AddInventoryView",
        type: "POST",
        data: {},
        success: function (result) {
            slideUpPullDownAdd();
            $("#pull-down-form").html(result);
            $("#pull-down-form").slideToggle("1000");
        }
    })
}